package com.leetcode.algorithm.y22.m07;

import com.leetcode.algorithm.common.TreeNode;

/**
 * 700. 二叉搜索树中的搜索
 * 
 * https://leetcode.cn/problems/search-in-a-binary-search-tree/
 * 
 * @author jie.deng
 *
 */
class Question0700Solution01 {
	
	public TreeNode searchBST(TreeNode root, int val) {
		if (root.val == val) {
			return root;
		} else if (root.val > val && root.left != null) {
			return searchBST(root.left, val);
		} else if (root.val < val && root.right != null) {
			return searchBST(root.right, val);
		}
		return null;
	}
    
}